home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / driverss.zip / UBNICPS2.ASM < prev    next >
Assembly Source File  |  1991-01-26  |  7KB  |  293 lines

  1. version    equ    1
  2.  
  3.     include    defs.asm
  4.  
  5. ;Ported from Tim Krauskopf's micnet.asm, an assembly language
  6. ;driver for the MICOM-Interlan NI5210 by Russell Nelson.  Any bugs
  7. ;are due to Russell Nelson.
  8. ;3c523 version Dan Lanciani ddl@harvard.* (received 5-18-89)
  9. ;Added Brad Clements' 1500 byte MTU, Russell Nelson.
  10. ;Changed it into a UB NIC-PS/2 driver, 10/90
  11.  
  12. ;  Copyright 1990, Russell Nelson
  13.  
  14. ;   This program is free software; you can redistribute it and/or modify
  15. ;   it under the terms of the GNU General Public License as published by
  16. ;   the Free Software Foundation, version 1.
  17. ;
  18. ;   This program is distributed in the hope that it will be useful,
  19. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;   GNU General Public License for more details.
  22. ;
  23. ;   You should have received a copy of the GNU General Public License
  24. ;   along with this program; if not, write to the Free Software
  25. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. code    segment    word public
  28.     assume    cs:code, ds:code
  29.  
  30. ;
  31. ;  Equates for controlling the ubnicps2 board
  32. ;
  33. IO_CSR    equ    0
  34. IO_CA    equ    1
  35.  
  36.     public    int_no
  37. int_no        db    3,0,0,0        ; interrupt number
  38. io_addr        dw    300h,0        ; I/O address for card
  39. base_addr    dw      0d000h,0    ; RAM segment for board
  40. eprom_addr    dw      0c000h,0    ; EPROM segment for board
  41.  
  42.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  43. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  44. driver_type    db    41        ;from the packet spec
  45. driver_name    db    "UB NIC-PS2",0    ;name of the driver.
  46. driver_function    db    2
  47. parameter_list    label    byte
  48.     db    1    ;major rev of packet driver
  49.     db    9    ;minor rev of packet driver
  50.     db    14    ;length of parameter list
  51.     db    EADDR_LEN    ;length of MAC-layer address
  52.     dw    GIANT    ;MTU, including MAC headers
  53.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  54.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  55.     dw    0    ;(# of successive xmits) - 1
  56. int_num    dw    0    ;Interrupt # to hook for post-EOI
  57.             ;processing, 0 == none,
  58.  
  59. enable_network:
  60. ;  connect to network
  61.     loadport
  62.     setport    IO_CSR            ; enable network
  63.     in    al,dx
  64.     and    al,not 2        ;turn off loopback.
  65.     or    al,8            ;turn on 82586 interrupts.
  66.     out    dx,al
  67.     ret
  68.  
  69.  
  70. reset_586:
  71. ;  Reset the chip
  72.     loadport
  73.     setport    IO_CSR
  74.     in    al,dx
  75.     or    al,1
  76.     out    dx,al        ; reset the chip
  77.     jmp    $+2
  78.     jmp    $+2
  79.     jmp    $+2
  80.     and    al,not 1
  81.     out    dx,al        ; done resetting the chip
  82.     jmp    $+2
  83.     jmp    $+2
  84.     jmp    $+2
  85.     ret
  86.  
  87.  
  88.     public    get_address
  89. get_address:
  90. ;get the address of the interface.
  91. ;enter with es:di -> place to get the address, cx = size of address buffer.
  92. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  93.     assume    ds:code
  94.     cmp    cx,EADDR_LEN        ;make sure that we have enough room.
  95.     jb    get_address_2
  96.     push    ds            ;save ds.
  97.     mov    ds,eprom_addr        ;point to the eprom.
  98.     mov    si,10h
  99.     mov    cx,EADDR_LEN
  100.     cld
  101. get_address_1:
  102.     lodsw                ;we have to get words,
  103.     stosb                ;  and store bytes.
  104.     loop    get_address_1        ; go back for rest
  105.     pop    ds
  106.     mov    cx,EADDR_LEN
  107.     clc
  108.     ret
  109. get_address_2:
  110.     stc
  111.     ret
  112.  
  113.  
  114. doca:
  115. ;we may be called from places in which ds is unknown.
  116.     assume    ds:nothing
  117.     loadport
  118.     setport IO_CA
  119.     out    dx, al
  120.     ret
  121.     assume    ds:code
  122. ;yet, we really should assume ds==code for the rest of this stuff.
  123.  
  124.  
  125. ;
  126. ; Here we include the code that is common between 82586 implementations.
  127. ; Everything above this is resident.
  128.     include    82586.asm
  129. ; Everything below this is discarded upon installation.
  130.  
  131.     public    usage_msg
  132. usage_msg    db    "usage: ubnicps2 [-n] [-d] [-w] <packet_int_no> <int_no> <io_addr> <base_addr>",CR,LF,'$'
  133.  
  134.     public    copyright_msg
  135. copyright_msg    db    "Packet driver for the ubnicps2, version ",'0'+majver,".",'0'+version,".",'0'+i82586_version,CR,LF,'$'
  136.  
  137. check_board:
  138.     mov    SCP,0            ; 16 bit bus type in scb.
  139.  
  140. ; search all slots for a ubnicps2 card
  141.     mov    cx, 8            ; for all channels(slots)
  142.  
  143. ; channel select value for slots 0,1,2.. is 8,9,A etc
  144. ; start with slot 0, and then 7,6,5,4,3,2,1
  145. get_05:
  146.     mov    ax, cx            ; channel number
  147.     or    ax, 08h            ; reg. select value
  148.     out    96h, al            ; select channel
  149.  
  150. ; read adapter id
  151.     mov    dx, 101h
  152.     in    al, dx            ; adapter id - ms byte
  153.     mov    ah, al
  154.     dec    dx
  155.     in    al, dx            ; adapter id - ls byte
  156.  
  157. ; Check if ubnicps2
  158.     cmp    ax, 0eff5h
  159.     je    get_10
  160.     loop    get_05
  161.  
  162.     mov    dx,offset no_ubnicps2_msg
  163.     jmp    error
  164.  
  165. get_10:
  166. ; found our Adapter
  167.  
  168. ; Get ubnicps2 I/O address
  169.     mov    dx,102h
  170.     in    al,dx
  171.     mov    bl,al
  172.     xor    bh,bh
  173.     shl    bx,1            ;should start at bit 2, now at bit 1.
  174.     and    bx,1ch
  175.     or    bx,1540h
  176.     mov    io_addr,bx
  177.  
  178. ; Set ubnicps2 IRQ.  Unbelievably, it only uses interrupt number 3.
  179.     mov    int_no,3
  180.  
  181. ; Get ubnicps2 RAM address
  182.     mov    dx,103h
  183.     in    al,dx
  184.     xor    bl,bl
  185.     mov    bh,al            ;put it in the high byte.
  186.     mov    cl,4
  187.     shl    bx,cl
  188.     mov    base_addr,bx
  189.  
  190. ; Get ubnicps2 EPROM address
  191.     mov    dx,104h
  192.     in    al,dx
  193.     xor    bl,bl
  194.     mov    bh,al            ;put it in the high byte.
  195.     mov    cl,4
  196.     shl    bx,cl
  197.     mov    eprom_addr,bx
  198.  
  199. ; Get ubnicps2 RAM address bits.
  200.     mov    dx,105h
  201.     in    al,dx
  202.     mov    bl,al
  203.     xor    bh,bh
  204.     mov    cl,10-0            ;should start at bit 10, now at bit 0.
  205.     shl    bx,cl
  206.     and    bx,0c00h
  207.     or    base_addr,bx
  208.  
  209. ; Get ubnicps2 EPROM address bits.
  210.     mov    dx,105h
  211.     in    al,dx
  212.     mov    bl,al
  213.     xor    bh,bh
  214.     mov    cl,10-2            ;should start at bit 10, now at bit 2.
  215.     shl    bx,cl
  216.     and    bx,0c00h
  217.     or    eprom_addr,bx
  218.  
  219.     mov    dx, 102h
  220.     in    al,dx
  221.     or    al,1            ;enable the card.
  222.     out    dx,al
  223.  
  224.     xor    al,al
  225.     out    96h,al            ;deselect the card.
  226.  
  227.   if 0
  228.     loadport
  229.     setport    IO_CSR
  230.     mov    al,23h
  231.     out    dx,al        ; reset the chip
  232.     jmp    $+2
  233.     jmp    $+2
  234.     jmp    $+2
  235.     mov    al,63h
  236.     out    dx,al        ; reset the chip
  237.     jmp    $+2
  238.     jmp    $+2
  239.     jmp    $+2
  240.     mov    al,23h
  241.     out    dx,al        ; reset the chip
  242.     jmp    $+2
  243.     jmp    $+2
  244.     jmp    $+2
  245.   endif
  246.  
  247.     ret
  248.  
  249. no_ubnicps2_msg    db    "No ubnicps2 found at that memory address.",CR,LF,'$'
  250.  
  251.     public    parse_args
  252. parse_args:
  253.     mov    di,offset int_no
  254.     call    get_number
  255.     mov    di,offset io_addr
  256.     call    get_number
  257.     mov    di,offset base_addr
  258.     call    get_number
  259.     clc
  260.     ret
  261.  
  262.  
  263. int_no_name    db    "Interrupt number ",'$'
  264. io_addr_name    db    "I/O port ",'$'
  265. base_addr_name    db    "Memory address ",'$'
  266.  
  267.  
  268.     public    print_parameters
  269. print_parameters:
  270.     mov    di,offset int_no
  271.     mov    dx,offset int_no_name
  272.     call    print_number
  273.     mov    di,offset io_addr
  274.     mov    dx,offset io_addr_name
  275.     call    print_number
  276.     mov    ax,memory_begin
  277.     mov    cl,4
  278.     shr    ax,cl
  279.     add    base_addr,ax
  280.     push    ax
  281.     mov    di,offset base_addr
  282.     mov    dx,offset base_addr_name
  283.     call    print_number
  284.     pop    ax
  285.     sub    base_addr,ax
  286.     ret
  287.  
  288.     include    memtest.asm
  289.  
  290. code    ends
  291.  
  292.     end
  293.